
<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    title="修改 用户日志"
    width="60%"
    draggable
    :close-on-click-modal="false"
    :before-close="hide"
  >
<el-form :model="form"  ref="form" :rules="rules">
  <el-row>
        <el-col :span="12">
        
     <!--用户 下拉控件 -->
     <el-form-item prop="user_id" label="用户" label-width="100px" label-position="right">
       <el-select   v-model="form.user_id" style="width: 100%" filterable clearable
         placeholder="请选择用户" >
         <el-option v-for="item in user_idList" :key="item.value" :label="item.name" :value="item.value" />
       </el-select>
     </el-form-item>
    </el-col>
        <el-col :span="12">
        
      <!--标题 输入控件 -->
      <el-form-item prop="title" label="标题" label-width="100px" label-position="right">
        <el-input clearable style="width: 100%" v-model="form.title"  maxlength="48" 
          :rows="0" 
          placeholder="请输入标题"  />
      </el-form-item>
    </el-col>
    
        <el-col :span="24">
      <!--内容 输入控件 -->
      <el-form-item prop="content" label="内容" label-width="100px" label-position="right">
        <el-input clearable style="width: 100%" v-model="form.content"  maxlength="2000" 
          :rows="0"  type="textarea" show-word-limit 
          placeholder="请输入内容"  />
      </el-form-item>
    </el-col>
</el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide">取消</el-button>
        <el-button type="primary" @click="save">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      conf: {
        visible: false,
        uploadPath:this.$theia.env.join("/file/upload"),
      },
    rules:{
      user_id:[{
          required:true,
          message:"请输入用户",
          trigger: 'blur',
      }],
      title:[{
          required:true,
          message:"请输入标题",
          trigger: 'blur',
      }],
      content:[{
          required:true,
          message:"请输入内容",
          trigger: 'blur',
      }],
    },
    form:{
        user_id:"",
        title:"",
        content:"",
        },
        user_idList:this.$theia.enum.get("user_account","",""),
      }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.get(form)
    },
      get(form){
        let that = this
        this.$theia.http.get("/sso/user/log",form).then(res=>{
        Object.assign(that.form, res)
        }).catch(res=>{
          let code = res.response.status
          let msg = `用户日志查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v){
                this.onSave()
            }
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        this.$theia.http.put("/sso/user/log",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '用户日志保存成功',duration:5000})
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
          let code = res.response.status
          let msg = `用户日志修改失败(${code})`
          that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
     onUploadSuccess(response){
    },
  },
};
</script>

<style>
</style>